package org.openit.portail.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.openit.portail.dao.ModeleParametreDao;
import org.openit.portail.model.ModeleParametre;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;


@Repository
@Transactional
public class ModeleParametreDaoImpl implements ModeleParametreDao {

	private SessionFactory sessionFactory;

	public ModeleParametre get(Long id) {
		return (ModeleParametre) sessionFactory.getCurrentSession()
			.createQuery("from ModeleParametre modeleparametre where modeleparametre.id = :id")
			.setLong("id", id).uniqueResult();
	}

	public void delete(ModeleParametre modeleparametre) {
		sessionFactory.getCurrentSession().delete(modeleparametre);
	}

	@SuppressWarnings("unchecked")
	public List<ModeleParametre> findAll() {
		return sessionFactory.getCurrentSession().createQuery("from ModeleParametre").list();
	}

	public void save(ModeleParametre modeleparametre) {
		sessionFactory.getCurrentSession().merge(modeleparametre);
		
	}
	
	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	
}
